package com.fau.ss.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.ss.action.PublicAction;
import com.fau.ss.entity.MedicalAdmin;
import com.fau.ss.entity.MedicalSsPerformance;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc 小组业绩统计Action
 * @author liy
 * @datetime 2014年11月3日,下午5:11:05
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class GroupPerformanceStaAction extends PublicAction implements ModelDriven<MedicalSsPerformance> {

	private static final long serialVersionUID = -4743165361566354326L;

	private MedicalSsPerformance performance = new MedicalSsPerformance();
	
	/**
	 * @desc 进入小组业绩统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年10月30日,下午9:54:13
	 */
	@Action(value = "group_performance_init", results = {@Result(name = SUCCESS, location = "group_performance_init.jsp")})
	public String init(){
		return SUCCESS;
	}
	
	/**
	 * @desc 小组业绩统计数据展示
	 * @return String
	 * @author dangjh
	 * @datetime 2014年11月19日,上午9:55:23
	 */
	@Action(value = "group_performance_view")
	public String view() {
		HttpServletResponse response = ServletActionContext.getResponse();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		map = ServletActionContext.getContext().getParameters();
		pageBean = this.baseAllService.getGroupService().findGroupPerformanceSta(map, performance, admin);
		map.clear();
		map.put("total", pageBean.getTotalRow());
		map.put("data", pageBean.getResult());
		formatJSON(response, map);
		return null;
	}
	
	@Override
	public MedicalSsPerformance getModel() {
		return performance;
	}
	
}
